#pragma once
#include<string>
// compile time calculation of basename of source file
namespace Log {
    class SourceFile
    {
    public:
        template<int N>
        SourceFile(const char(&arr)[N])
            : data_(arr),
            size_(N - 1)
        {
            const char* slash = strrchr(data_, '/'); // builtin function
            if (slash)
            {
                data_ = slash + 1;
                size_ -= static_cast<int>(data_ - arr);
            }
        }

        explicit SourceFile(const char* filename)
            : data_(filename)
        {
            const char* slash = strrchr(filename, '/');
            if (slash)
            {
                data_ = slash + 1;
            }
            size_ = static_cast<int>(strlen(data_));
        }

        const char* data()const { return data_; }
        int size()const { return size_; }

        const char* data_;
        int size_;
    };
}
